{extend name="public/base" /}
{block name="main"}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span> 用户列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
        <form action="" method="get">
            <div class="text-c">
                <input type="text" value="<?php echo $search['title']?>"  class="input-text" style="width:250px" placeholder="输入用户名称" id="" name="title">
                <button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
            </div>
        </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> <a href="javascript:;" onclick="admin_add('添加律师用户','{:url('User/cu')}','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加律师</a></span>  </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="9">用户列表</th>
        </tr>
        <tr class="text-c">
            <th width="25"><input type="checkbox" name="" value=""></th>
            <th width="40">ID</th>
            <th width="150">登录名</th>
            <th>用户身份</th>
            <th width="130">加入时间</th>
            <th width="100">是否已启用</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($list as $v){?>
        <tr class="text-c">
            <td><input type="checkbox" value="1" name=""></td>
            <td><?php echo $v['id']?></td>
            <td><?php echo $v['username']?></td>
            <td><?= $v['type']==1?'普通会员':'律师'?></td>
            <td><?php echo date('Y-m-d H:i:s',$v['time'])?></td>
            <td class="td-status">
                <span class="<?php echo $v['status']==1 ? 'label label-success radius':'label radius'?>"><?php echo $v['status']==1 ? '已启用':'已禁用'?>
                </span>
            </td>
            <td class="td-manage">
                <a style="text-decoration:none" onClick="changeStatus(<?php echo $v['id']?>,<?=$v['status'] == 1 ? 2 : 1?>,'status','<?php echo $v['status'] == 1 ? '你确认要禁用么？':'你确认要启用么？'?>')" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>
                <a style="text-decoration:none" class="ml-5" onClick="change_password('修改密码','<?php echo url('user/resetPwd',['id'=>$v['id']])?>','500','400')" href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>
            </td>
        </tr>
        <?php }?>
        </tbody>
    </table>
    </form>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*管理员-增加*/
    function admin_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-增加*/
    function change_password(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-编辑*/
    function admin_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员状态改变*/
    function changeStatus(id,value,field,message){
        layer.confirm(message,function(index){
            console.log(id);
            console.log(value);
            console.log(field);
            $.ajax({
                type:'post',
                url:"<?php echo url('universal/changeStatus')?>",
                data:{'table_name':'user','id':id,'field':'status','value':value},
                success:function(data){
                    if(typeof data === 'string'){
                        data = jQuery.parseJSON(data);
                    }
                    if(data.code == 10000){
                        layer.msg(data.msg,{icon: 1,time:1000});
                        setInterval("loadPage()",1200);
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }
                }
            });
        });
    }
    function loadPage() {
        location.reload();
    }
</script>
{/block}